#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int main()
{
    int a;
    int b;
    int c;

    scanf("%d %d", &a, &b);

    while (a % b != 0)
    {
        c = a % b;
        a = b;
        b = c;

    }

    printf("%d", b);

    return 0;
}